package org.wat.wcy.isi.mmazur.bp;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;

import org.wat.wcy.isi.mmazur.bp.io.BPService;
import org.wat.wcy.isi.mmazur.bp.io.BPService_Service;

public class FacadeProvider {
	
    private static BPService_Service service;
	
	private static BPService port;
	private static String address;
	
	private FacadeProvider() {
		
	}
	
	
	
	public static void setAddress(String address) throws MalformedURLException {
		URL url = new URL(address + "/bp-ws/BPService");
		service = new BPService_Service(new URL(address + "/bp-ws/BPService"),new QName("http://io.bp.mmazur.isi.wcy.wat.org/","BPService"));
		port = service.getBPServicePort();
		FacadeProvider.address = address;
	}



	public static BPService getBPFacade() {
		if (port == null) {
			try {
				service = new BPService_Service(new URL(address + "/bp-ws/BPService"),new QName("http://io.bp.mmazur.isi.wcy.wat.org/","BPService"));
				port = service.getBPServicePort();
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
		}
		return port;
	}
}
